unit fHalfSphere;

interface

uses
  Winapi.Windows,
  Winapi.Messages,
  System.SysUtils,
  System.Variants,
  System.Classes,

  Vcl.Graphics,
  Vcl.Controls,
  Vcl.Forms,
  Vcl.Dialogs,

  GLS.Scene,
  GLS.Coordinates,
  GLS.Objects,
  GLS.State,
  GLS.SimpleNavigation,
  GLS.SceneViewer,
  GLS.BaseClasses,
  GLS.Material,
  GLS.RenderContextInfo,
  GLSL.UserShader;

type
  TFormHalfSphere = class(TForm)
    GLScene1: TGLScene;
    GLSceneViewer1: TGLSceneViewer;
    GLMaterialLibrary1: TGLMaterialLibrary;
    GLSimpleNavigation1: TGLSimpleNavigation;
    GLSphere1: TGLSphere;
    GLCamera1: TGLCamera;
    GLLightSource1: TGLLightSource;
    GLUserShader1: TGLUserShader;
    procedure GLUserShader1DoUnApply(Sender: TObject; Pass: Integer; var rci: TGLRenderContextInfo;
      var Continue: Boolean);
    procedure GLUserShader1DoApply(Sender: TObject; var rci: TGLRenderContextInfo);
  private
  public
  end;

var
  FormHalfSphere: TFormHalfSphere;

implementation

{$R *.dfm}

procedure TFormHalfSphere.GLUserShader1DoApply(Sender: TObject; var rci: TGLRenderContextInfo);
begin
  rci.GLStates.Enable(stCullFace);
  rci.GLStates.CullFaceMode := cmBack;
end;

procedure TFormHalfSphere.GLUserShader1DoUnApply(Sender: TObject; Pass: Integer;
  var rci: TGLRenderContextInfo; var Continue: Boolean);
begin
  if Pass > 1 then
  begin
    Continue := False;
    rci.GLStates.FrontFace := fwCounterClockWise;
  end
  else
  begin
    rci.GLStates.PolygonMode := pmLines;
    rci.GLStates.CullFaceMode := cmFront;
    Continue := True;
  end;
end;

end.
